package com.zhoujian.Prototype.DeepCopy;

import lombok.Data;

import java.io.Serializable;

/**
 * 促销规则
 *
 * 手动的去递归克隆
 */
@Data
public class PromotionRule implements Cloneable, Serializable {
    private String type;
    private double discount;
    private Product product;

    @Override
    public Object clone() throws CloneNotSupportedException {
        PromotionRule promotionRule = (PromotionRule)super.clone();
        if (product != null){
            Product cloneProduct = (Product) product.clone();
            promotionRule.setProduct(cloneProduct);
        }
        return promotionRule;
    }
}
